package com.example.thread.demo.volatilefeature;

/**
 * Created by Administrator on 2020/07/14 0014.
 */
public class VolatileFeaturesExampleApplication {

    public static void main(String[] args) throws InterruptedException {
        VolatileFeaturesExample volatileFeaturesExample = new VolatileFeaturesExample();
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                volatileFeaturesExample.set(1);
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                volatileFeaturesExample.get();
            }
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        System.out.println(volatileFeaturesExample.get());
    }
}
